<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('人员关系')" />
	<th:block th:include="include :: layout-latest-css" />
</head>
<body class="gray-bg">
	<div class="ui-layout-center">
		<div class="container-div">
			<div class="row">
			    <div class="col-sm-12 search-collapse">
                    <form id="user-form" th:object="${releation}">
                        <div class="select-list">
                            <ul>
                                <li>
                                                                                                             关系人：<input type="text" name="fromName"/>
                                </li>
                                <li>
                                                                                                             被关系人：<input type="text" name="toName"/>
                                </li>
                                <li>
                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                </li>
                            </ul>
                        </div>
                    </form>
                </div>
		        <div class="btn-group-sm" id="toolbar" role="group">
		        	<a class="btn btn-success" onclick="addReleation()" shiro:hasPermission="system:people:add">
		                <i class="fa fa-plus"></i> 新增
		            </a>
		            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:people:remove">
		                <i class="fa fa-remove"></i> 删除
		            </a>
		        </div>
		        
		        <div class="col-sm-12 select-table">
		            <div class="row">
			            <div class="col-sm-4">姓名：[[${people.name}]]</div>
			            <div class="col-sm-4">权重：[[${people.symbol}]]</div>
			            <div class="col-sm-4">颜色：[[${people.color}]]</div>
		            </div>
		        </div>
		        <div class="col-sm-12 select-table table-striped">
				    <table id="bootstrap-table"></table>
				</div>
			</div>
		</div>
	</div>
	
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: layout-latest-js" />
	<script th:inline="javascript">
		var prefix = ctx + "releation";

		$(function() {
		    var panehHidden = false;
		    if ($(this).width() < 769) {
		        panehHidden = true;
		    }
		    $('body').layout({ initClosed: panehHidden, west__size: 185 });
		    queryUserList();
		});
		
		function addReleation(){
			//$.operate.addTab([[${people.id}]])
			$.modal.openTab("添加关系", ctx + "releation/add/" + [[${people.id}]])
		}

		function queryUserList() {
		    var options = {
		        url: prefix + "/list",
		        createUrl: prefix + "/add",
		        removeUrl: prefix + "/remove",
		        sortName: "fromId",
		        modalName: "人员关系",
		        columns: [{
		            checkbox: true
		        },
		        {
		            field: 'toId',
		            title: '人员ID'
		        },
		        {
		            field: 'toName',
		            title: '姓名',
		            sortable: true
		        },
		        {
		            field: 'releationName',
		            title: '关系',
		        },
		        {
		            field: 'releationDesc',
		            title: '关系描述',
		        },
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		                var actions = [];
		                actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
		                return actions.join('');
		            }
		        }]
		    };
		    $.table.init(options);
		}
	</script>
</body>
</html>